<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../../plugins/element-ui/index.css"/>
    <link rel="stylesheet" href="../../styles/common.css"/>
    <link rel="stylesheet" href="../../styles/page.css"/>
    <style>
        #member-app .notAdmin::after {
            border: 0 !important;

        }
    </style>
</head>
<body>
<div class="dashboard-container" id="category-app">
    <div class="container">

        <el-table
                :data="tableData"
                stripe
                class="tableBox"
        >
            <el-table-column
                    prop="userName"
                    label="反馈用户"
            />
            </el-table-column>

            <el-table-column
                    prop="type"
                    label="反馈类型"
            >
            </el-table-column>

            <el-table-column
                    prop="createTime"
                    label="反馈时间"
            >
            </el-table-column>
            <el-table-column
                    prop="updateTime"
                    label="最新受理时间"
            >
                <template slot-scope="scope">
                    {{scope.row.updateTime}}
                </template>
            </el-table-column>

            <el-table-column
                    prop="status"
                    label="状态"
            />
            <template slot-scope="scope">
                <span>{{ scope.row.status == '1' ? '已处理': '未处理' }}</span>
            </template>
            </el-table-column>

            <el-table-column
                    prop="updateUser"
                    label="受理人"
            />
            </el-table-column>

            <el-table-column
                    label="操作"
                    width="160"
                    align="center"
            >
                <template slot-scope="scope">

                    <el-button
                            type="text"
                            size="small"
                            class="blueBug"
                            @click="editHandle(scope.row)"
                    >
                        查看
                    </el-button>

                    <el-button
                            type="text"
                            size="small"
                            class="delBut non"
                            @click="deleteHandle(scope.row.id)"
                    >
                        删除
                    </el-button>

                </template>
            </el-table-column>
        </el-table>


        <el-pagination
                class="pageList"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="counts"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
        ></el-pagination>
    </div>


    <el-dialog
            :title="classData.title"
            :visible.sync="classData.dialogVisible"
            width="30%"
            :before-close="handleClose"
    >
        <el-form
                class="demo-form-inline"
                label-width="100px"
        >
            <el-form-item label="反馈用户：">
                <span>{{classData.userName}}</span>
            </el-form-item>

            <el-form-item label="反馈类型：">
                <span>{{classData.type}}</span>
            </el-form-item>

            <el-form-item label="反馈时间：">
                <span>{{classData.createTime}}</span>
            </el-form-item>

            <el-form-item label="受理状态：">
                <span>{{classData.status == '1' ? '已处理': '未处理' }}</span>
            </el-form-item>

            <el-form-item label="受理人：">
                <span>{{classData.updateUser}}</span>
            </el-form-item>

            <el-form-item label="反馈内容：">
                <span>{{classData.content}}</span>
            </el-form-item>


        </el-form>


        <span
                slot="footer"
                class="dialog-footer"
        >
        <el-button
                size="medium"
                @click="classData.dialogVisible = false"
        >取 消
        </el-button>

        <el-button
                type="primary"
                size="medium"
                @click="submitForm()"
                :disabled="classData.status == 1 ? true : false"
        >
            {{classData.status == '1' ? '已受理' : '确认受理' }}
        </el-button>

      </span>
    </el-dialog>
</div>
<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="../../plugins/vue/vue.js"></script>
<!-- 引入组件库 -->
<script src="../../plugins/element-ui/index.js"></script>
<!-- 引入axios -->
<script src="../../plugins/axios/axios.min.js"></script>
<script src="../../js/request.js"></script>
<script src="../../api/feedback.js"></script>
<script>
    new Vue({
        el: '#category-app',
        data() {
            return {
                action: '',
                counts: 0,
                page: 1,
                pageSize: 10,
                tableData: [],
                type: '',
                classData: {
                    'title': '受理',
                    'dialogVisible': false,
                    'feedbackId': '',
                    'name': '',
                    sort: ''
                }
            }
        },
        computed: {},
        created() {
            this.init()

        },
        mounted() {
        },
        methods: {
            async init() {
                await getFeedbackPage({'page': this.page, 'pageSize': this.pageSize}).then(res => {
                    if (String(res.code) === '1') {
                        this.tableData = res.data.records
                        this.counts = Number(res.data.total)
                    } else {
                        this.$message.error(res.msg || '操作失败')
                    }
                }).catch(err => {
                    this.$message.error('请求出错了：' + err)
                })
            },
            handleQuery() {
                this.page = 1;
                this.init();
            },

            editHandle(dat) {
                this.classData.title = '查看反馈内容'
                this.action = 'edit'
                this.classData.userName = dat.userName
                this.classData.createTime = dat.createTime
                this.classData.status = dat.status
                this.classData.updateUser = dat.updateUser
                this.classData.type = dat.type
                this.classData.content = dat.content
                this.classData.id = dat.id
                this.classData.dialogVisible = true
                this.classData.status = dat.status
            },
            // 关闭弹窗
            handleClose(st) {
                this.classData.dialogVisible = false
            },
            //删除
            deleteHandle(id) {
                this.$confirm('此操作将永久删除该反馈记录, 是否继续?', '提示', {
                    'confirmButtonText': '确定',
                    'cancelButtonText': '取消',
                    'type': 'warning'
                }).then(() => {
                    deleteFeedback(id).then(res => {

                        if (res.code === 1) {
                            this.$message.success('删除成功！')
                            this.handleQuery()
                        } else {
                            this.$message.error(res.msg || '操作失败')
                        }
                    }).catch(err => {
                        this.$message.error('请求出错了：' + err)
                    })
                })
            },


            //数据提交
            submitForm(st) {
                const classData = this.classData
                const valid = (classData.type === 0 || classData.type) && (classData.content === 0 || classData.content)
                if (valid) {
                    editFeedback({
                        'id': this.classData.id,
                        'type': this.classData.type,
                        content: this.classData.content
                    }).then(res => {
                        if (res.code === 1) {
                            this.$message.success('反馈问题已受理成功！')
                            this.classData.dialogVisible = false
                            this.handleQuery()
                        } else {
                            this.$message.error(res.msg || '操作失败')
                        }
                    }).catch(err => {
                        this.$message.error('请求出错了：' + err)
                    })

                }
            },
            handleSizeChange(val) {
                this.pageSize = val
                this.init()
            },
            handleCurrentChange(val) {
                this.page = val
                this.init()
            }
        }
    })
</script>
</body>
</html>